// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   delete_ok.java

package security.license;

import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class delete_ok extends HttpServlet
{

	public delete_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		HttpSession session = request.getSession();
		nseer_db_backup1 security_db = new nseer_db_backup1(dbApplication);
		try
		{
			if (security_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String human_ID = request.getParameter("human_ID");
				String id = request.getParameter("id");
				String sql1 = (new StringBuilder("delete from security_license where id='")).append(id).append("'").toString();
				security_db.executeUpdate(sql1);
				int amount = 0;
				String sql = "select count(*) from document_main";
				ResultSet rs = security_db.executeQuery(sql);
				if (rs.next())
					amount = rs.getInt("count(*)");
				String str[] = new String[amount];
				int n = 0;
				sql = "select * from document_main";
				for (rs = security_db.executeQuery(sql); rs.next();)
				{
					str[n] = rs.getString("reason");
					n++;
				}

				for (int i = 0; i < str.length; i++)
				{
					String table1 = (new StringBuilder(String.valueOf(str[i]))).append("_view").toString();
					sql = (new StringBuilder("delete from ")).append(table1).append(" where human_ID='").append(human_ID).append("'").toString();
					security_db.executeUpdate(sql);
				}

				sql = (new StringBuilder("delete from security_workspace where human_ID='")).append(human_ID).append("'").toString();
				security_db.executeUpdate(sql);
				String sql2 = (new StringBuilder("update hr_file set license_tag='0' where human_ID='")).append(human_ID).append("'").toString();
				security_db.executeUpdate(sql2);
				response.sendRedirect("security/license/delete_list.jsp");
				security_db.commit();
				security_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
